package com.util;

import java.util.Objects;

/**
 * @Author chl
 * @Description Administrator
 * @Date 17:40 2021/4/23
 **/
public enum BussiEnum {
    SCUESS(200, "成功"),
    ERROR(500, "失败"),
    PRECONDITIONS(412, "前提条件不足"),
    TOKEN_USELESS(10001,"Token失效");

    private Integer code;
    private String msg;

    private BussiEnum(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static String getBussiEunmName(Integer code) {
        if (Objects.isNull(code)) {
            return "";
        }
        for (BussiEnum value : BussiEnum.values()) {
            if (code.equals(value.code)) {
                return value.msg;
            }
        }
        return "";
    }

    public static void main(String[] args) {
        String bussiEunmName = getBussiEunmName(500);
        System.out.println(" :" +bussiEunmName);
    }

    public Integer getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }
}
